<?php
/**
 * @version $Id: spamcheck.php 174 2008-02-24 15:56:02Z mikhail.miguel $
 */
/**
 * Services_Trackback_SpamCheck.
 *
 * This is the base class for Services_Trackback spamchecks. Since PHP4
 * lacks abstract class support, this class acts like a virtual abstract class. 
 * Each SpamCheck implementation has to extend this class and implement all of it's
 * abstract methods.
 *
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @abstract
 * @category   Webservices
 * @package    Trackback
 * @author     Tobias Schlitt <toby@php.net>
 * @copyright  2005-2006 The PHP Group
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * @link       http://pear.php.net/package/Services_Trackback
 * @since      File available since Release 0.5.0
 */

class SpamCheck {

    var $_options = array(
        'sources'       => array(),
        'elements'      => array()
    );
    var $_results = false;

    function &create($type, $options=null) {
        $filename = dirname(dirname(dirname(__FILE__))).'/lib/trackback/SpamCheck/' . $type . '.php';
        $filepath = dirname(dirname(dirname(__FILE__))).'/lib/trackback/SpamCheck/'.$type.'.php';
        $classname = 'SpamCheck_' . $type;

        // Check if class already exists or is includeable
        if (!class_exists($classname)) {
            if (file_exists($filepath)) {
                include_once $filename;
            } 
        }
       
        if (!class_exists($classname)) {
            return TrackbackService::setError('SpamCheck ' . $type . ' not found.');
        }
        return new $classname(@$options);
    }
    
    function &check($trackback) {
        foreach ($this->_options['sources'] as $source) {
        	$result = $this->_checkSource($source, $trackback);
            if(TrackbackService::isError($result)) {
            	$this->_results = true;
                return $result;
            }
        }
        return false;
    }

    function _checkSource($source, $trackback) {	
    }

    function reset()
    {
        $this->_results = array();
    }

}
?>